home *** CD-ROM | disk | FTP | other *** search
/ PC Media 23 / PC MEDIA CD23.iso / share / prog / regem / checkreg.c next >
Encoding:
C/C++ Source or Header  |  1994-10-18  |  2.9 KB  |  74 lines

  1. /****************************************************************************
  2.    CHECKREG.C - Validates a key created by REG'EM
  3. ****************************************************************************/
  4.  
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <stdlib.h>
  8. #define REGEM 99999 /* <<<<<<<<<<<<< This Number should not be changed.*/
  9.                     /* program may not work proper if changed. */
  10.                     /* this tells the key maker how many different   */
  11.                     /* combination's of key seed's are possible, and to */
  12.                     /* hide your program code you entered when you Added*/
  13.                     /* your program to the list. That way there is */
  14.                     /* no library to link to your source. 99999 and your*/
  15.                     /* 5 diget key code with the Xor and Other */
  16.                     /* calculations the maker uses make a 13 diget */
  17.                     /* key for your program. */
  18.                     
  19.                     /* We recomend that you remove all comments from this*/
  20.                     /* file before your final compile !!! More Below */
  21.  
  22. char r_name[27];
  23. char r_full_number[20];
  24. long r_key;
  25. long r_number;
  26. int checkem(void)
  27. {
  28.     int count=0;
  29.     int r_counter=0;
  30.     char temp[20];
  31.     FILE *config_file;   /*vvvvvvvvv Enter Your Key file Name Here */
  32.     if((config_file=fopen("regem.key","r"))==NULL)
  33.         fclose(config_file);
  34.     fgets(r_name,27,config_file);           
  35.     fgets(r_full_number,20,config_file);    
  36.     *strchr(r_name, '\n') = '\0';
  37.     *strchr(r_full_number, '\n') = '\0';
  38.     while(r_name[count]!='\0')
  39.         {
  40.         r_counter=r_counter+r_name[count];
  41.         count++;
  42.         }
  43.     temp[0]='\0';
  44.     strncpy(temp,r_full_number,6);
  45.     r_key=atol(temp);
  46.     temp[0]='\0';
  47.     count=0;
  48.     while(r_full_number[count+6]!='\0')
  49.         {
  50.         temp[count]=r_full_number[count+6];
  51.         count++;
  52.         }
  53.     r_number=atol(temp);
  54.     r_key=r_key^REGEM;
  55.     if(r_number!=r_counter*r_key || r_number==0)
  56.        {
  57.        fclose(config_file);                          /* This re-writes the*/
  58.        if((config_file=fopen("regem.key","w"))==NULL)/* key file if the key*/
  59.            return(1);                                /* is invalid */
  60.        stpcpy(r_name,"unregistered copy");           /* Put whatever you */
  61.        r_full_number[0]='0';                       /* want for unregistered */
  62.        r_full_number[1]='\0';                      /* here */
  63.        fprintf(config_file,"%s\n%s",r_name,r_full_number);
  64.        fclose(config_file);
  65.        #include "text.c"
  66.        return(0);
  67.        }
  68.     fclose(config_file);                         /* Put what ever you want */
  69.     clrscrn2(0x1f);                              /* for registered version */
  70.     printf("\nRegistered Copy! \n"); /* here */
  71.     sleep(2);
  72.     return(0);
  73. }
  74.